/*********************\
* Author:Dzlua
* QQ:505544956
* Time:2017/04/11
\**********************/
#ifndef __LUA_CONTROL_H__
#define __LUA_CONTROL_H__
#pragma once

#include "../Base/LuaHelper.h"
#include <spdui/spdui.h>

namespace DuiLib {

class LuaControl : public LuaClassBase
{
    SDLUA_CLASS_DECLARE(LuaControl);

    int SetEvent(LuaState *L);
    int RemoveEvent(LuaState *L);
    
    //=================================================//
    int GetName(LuaState *L);
	int SetName(LuaState *L);

    //int GetClass(LuaState *L);
    //LPVOID GetInterface(LPCTSTR pstrName);
    //UINT GetControlFlags();

    bool Activate();
    /*CPaintManagerUI* GetManager();
    void SetManager(CPaintManagerUI* pManager, CControlUI* pParent, bool bInit = true);*/
    int Window(LuaState *L);
    int GetParent(LuaState *L);
    //void setInstance(HINSTANCE instance = NULL) {m_instance = instance;};
    
    bool SetTimer(UINT nTimerID, UINT nElapse);
    void KillTimer(UINT nTimerID);

    int GetText(LuaState *L);
    int SetText(LuaState *L);

    bool IsResourceText();
    void SetResourceText(bool bResource);

    bool IsDragEnabled();
    void SetDragEnable(bool bDrag);

    bool IsDropEnabled();
    void SetDropEnable(bool bDrop);

    int GetGradient(LuaState *L);
    int SetGradient(LuaState *L);
    DWORD GetBkColor();
    void SetBkColor(DWORD dwBackColor);
    DWORD GetBkColor2();
    void SetBkColor2(DWORD dwBackColor);
    DWORD GetBkColor3();
    void SetBkColor3(DWORD dwBackColor);
    DWORD GetForeColor();
    void SetForeColor(DWORD dwForeColor);
    int GetBkImage(LuaState *L);
    int SetBkImage(LuaState *L);
    int GetForeImage(LuaState *L);
    int SetForeImage(LuaState *L);

    DWORD GetFocusBorderColor();
    void SetFocusBorderColor(DWORD dwBorderColor);
    bool IsColorHSL();
    void SetColorHSL(bool bColorHSL);
    int GetBorderRound(LuaState *L);
    int SetBorderRound(LuaState *L);
    //bool DrawImage(HDC hDC, LPCTSTR pStrImage, LPCTSTR pStrModify = NULL);

    int GetBorderSize();
    int SetBorderSize(LuaState *L);
    DWORD GetBorderColor();
    void SetBorderColor(DWORD dwBorderColor);
    int GetLeftBorderSize();
    void SetLeftBorderSize(int nSize);
    int GetTopBorderSize();
    void SetTopBorderSize(int nSize);
    int GetRightBorderSize();
    void SetRightBorderSize(int nSize);
    int GetBottomBorderSize();
    void SetBottomBorderSize(int nSize);
    int GetBorderStyle();
    void SetBorderStyle(int nStyle);

    int GetRelativePos(LuaState *L);
    int GetClientPos(LuaState *L);
    int GetPos(LuaState *L);
    int SetPos(LuaState *L);
    int Move(LuaState *L);
    int GetWidth();
    int GetHeight();
    int GetX();
    int GetY();
    int GetPadding(LuaState *L);
    int SetPadding(LuaState *L);
    int GetFixedXY(LuaState *L);
    int SetFixedXY(LuaState *L);
    
    int GetFixedWidth();
    void SetFixedWidth(int cx);
    int GetFixedHeight();
    void SetFixedHeight(int cy);
    int GetMinWidth();
    void SetMinWidth(int cx);
    int GetMaxWidth();
    void SetMaxWidth(int cx);
    int GetMinHeight();
    void SetMinHeight(int cy);
    int GetMaxHeight();
    void SetMaxHeight(int cy);
    //TPercentInfo GetFloatPercent();
    //void SetFloatPercent(TPercentInfo piFloatPercent);
    void SetFloatAlign(UINT uAlign);
    UINT GetFloatAlign();
    
    int GetToolTip(LuaState *L);
    int SetToolTip(LuaState *L);
    void SetToolTipWidth(int nWidth);
    int	 GetToolTipWidth(void);

    WORD GetCursor();
    void SetCursor(WORD wCursor);

    int GetShortcut(LuaState *L);
    int SetShortcut(LuaState *L);

    bool IsContextMenuUsed();
    void SetContextMenuUsed(bool bMenuUsed);

    int GetUserData(LuaState *L);
    int SetUserData(LuaState *L);
    UINT_PTR GetTag();
    void SetTag(UINT_PTR pTag);

    bool IsVisible();
    void SetVisible(bool bVisible);
    void SetInternVisible(bool bVisible);
    bool IsEnabled();
    void SetEnabled(bool bEnable);
    bool IsMouseEnabled();
    void SetMouseEnabled(bool bEnable);
    bool IsKeyboardEnabled();
    void SetKeyboardEnabled(bool bEnable);
    bool IsFocused();
    void SetFocus();
    bool IsFloat();
    void SetFloat(bool bFloat);

    //CControlUI* FindControl(FINDCONTROLPROC Proc, LPVOID pData, UINT uFlags);

    void Invalidate();
    /*bool IsUpdateNeeded();
    void NeedUpdate();
    void NeedParentUpdate();*/
    DWORD GetAdjustColor(DWORD dwColor);

    /*void Init();
    void DoInit();

    void Event(TEventUI& event);
    void DoEvent(TEventUI& event);

    void AddCustomAttribute(LPCTSTR pstrName, LPCTSTR pstrAttr);
    LPCTSTR GetCustomAttribute(LPCTSTR pstrName);
    bool RemoveCustomAttribute(LPCTSTR pstrName);
    void RemoveAllCustomAttribute();

    void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
    CControlUI* ApplyAttributeList(LPCTSTR pstrList);*/

    int EstimateSize(LuaState *L);

    /*void DoPaint(HDC hDC, const RECT& rcPaint);
    void PaintBkColor(HDC hDC);
    void PaintBkImage(HDC hDC);
    void PaintStatusImage(HDC hDC);
    void PaintForeColor(HDC hDC);
    void PaintForeImage(HDC hDC);
    void PaintText(HDC hDC);
    void PaintBorder(HDC hDC);

    void DoPostPaint(HDC hDC, const RECT& rcPaint);*/

    int SetVirtualWnd(LuaState *L);
    int GetVirtualWnd(LuaState *L);
};

}

#endif //__LUA_CONTROL_H__